package cn.wx.controller;

import cn.wx.domain.Josnre;
import cn.wx.domain.Product;
import cn.wx.domain.Store;
import cn.wx.mapper.ProductMapper;
import cn.wx.openfeign.StoreOpenFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/product")
public class ProductController {

    @Autowired
    private ProductMapper productMapper;

    @Autowired
    private StoreOpenFeign storeOpenFeign;

    @PostMapping
    public Josnre add(@RequestBody Product product){
        productMapper.add(product);
        Store store = new Store();
        store.setProduct_id(product.getId());
        Josnre add = storeOpenFeign.add(store);
        if (!add.getSuccess()) {
            return add;
        }
        return new Josnre();


    }



}
